package com.wedata.腾讯;

import cn.hutool.crypto.digest.MD5;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import com.disdr.datacenter.HttpJsonUtil;
import com.wedata.HttpUtils;
import okhttp3.*;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class 企业微信 {

    //"requestBody":"{\"corpid\":\"wwbdeaa3266417c5e1\",\"agentId\":\"1000035\",\"externalUserId\":[\"wmZw2MCQAAK_CJmpbLUBq_lgmtOmH1xQ\"],\"sender\":\"ChenShuHan\",\"text\":{\"content\":\"你好请查收\"},
    //\"attachments\":[{\"msgtype\":\"image\",\"image\":{\"picUrl\":\"https://wework.qpic.cn/wwpic3az/962503_3hM4LEBXS-SzSJD_1708510582/0\"}}]}"

    //-type":"application/json","x-forwarded-for":"47.95.112.14","user-agent":"GuzzleHttp/7"},"requestBody":"{\"corpid\":\"wwbdeaa3266417c5e1\",\"agentId\":\"1000035\",\"externalUserId\":[\"wmZw2MCQAAK_CJmpbLUBq_lgmtOmH1xQ\"],\"se

    public static void main(String[] args) {
        postRequestWithSign();
    }
    public static void getUserId() {
        String url = "https://wedata.gymcity.com.cn/message/qiwei/user/getuserid";
        JSONObject param = new JSONObject();
        param.put("corpid","wwbb3eaebf35674eef");
        param.put("agentId","1000008");
        //param.put("mobile","18670715634"); //李潇
        //param.put("mobile","15273132129"); //黄筠筠
        param.put("mobile","13670279423"); //YangLin
        JSONObject header = new JSONObject("{\"X-AUTH-SECRET\":\"252b1c7cf1045d6a04c0bf64fc0504bf374712ac\"}");
        HttpUtils.sendPost(url,header,param);
        //sendRequest result:{"code":200,"msg":"操作成功","data":"LiXiao","time":1715763342}
    }
    public static void sendMessage() {
        String url = "https://twedata.gymcity.com.cn/message/qiwei/sendMessage";
        //String url = "http://localhost:8085/message/qiwei/sendMessage";
        JSONObject param = new JSONObject();
        param.put("corpid", "wwbb3eaebf35674eef");
        param.put("agentId", "1000009");

        param.put("touser", "YangLin");
        param.put("msgtype", "file");
        param.put("safe", 1);

        JSONObject content = new JSONObject();
        content.put("media_id", "3Qz3NqrLE93MaXTVegKYLqUIEjlGkEGpuLj9uGJOeo0jJ5wgnh4cb_CfCPbxGcw80");
        param.put("content", content);

        HttpUtils.sendPost(url,param);
        //sendRequest result:{"code":500,"msg":"获取统一Token失败","data":null,"time":1715763582}
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"errcode":0,"errmsg":"ok","msgid":"3yzdAQ63LCLTa8NCVqmn2bKPA4ZVpqtVdqyyGUTNPhTILRVc9arFVOE4S3g5GidhS8uD_O3lLTZRgMD0cFqHDA"},"time":1715764249}
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"errcode":0,"errmsg":"ok","msgid":"mqb78JKVOX4JWfYmNm2fYyO7WTbYo2eBzM49LqFdz-Kic4ZrJyIp2DxJV5cg_7myl8exTGozpm8rmvyu41suBw"},"time":1715764422}
    }

    /**
     * 上传临时素材---素材上传得到media_id，该media_id仅三天内有效
     * https://developer.work.weixin.qq.com/document/path/90389
     */
    private static String uploadMedia(){
        //String url = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?type=file&access_token="+postRequestWithSign();
        String url = "https://twedata.gymcity.com.cn/message/qiwei/uploadMedia";
        //String url = "http://localhost:8085/message/qiwei/uploadMedia";
        Map<String,String> param = new HashMap<>();
        param.put("corpid","wwbb3eaebf35674eef");
        param.put("agentId","1000009");
        Map<String, File> fileMap = new HashMap<>();
        File file = new File("E:\\工资条测试版.xlsx");
        fileMap.put("multipart",file);
        try{
            OkHttpClient okHttpClient = new OkHttpClient();
            RequestBody requestBody = new MultipartBody.Builder()
                    .setType(MultipartBody.FORM)
                    .addFormDataPart("corpid","wwbb3eaebf35674eef")
                    .addFormDataPart("agentId","1000009")
                    .addFormDataPart("file", "工资条测试版.xlsx",
                            RequestBody.create(MediaType.parse("application/vnd.ms-excel"),file))
                    .build();
            Request request = new Request.Builder().url(url).post(requestBody).build();
            Response response = okHttpClient.newCall(request).execute();
            ResponseBody body = response.body();
            String str = new String(body.bytes());
            System.out.println(str);
            return new JSONObject(str).getStr("media_id");
            //{"code":200,"msg":"操作成功","data":{"errcode":0,"errmsg":"ok","type":"file","media_id":"3Qz3NqrLE93MaXTVegKYLqUIEjlGkEGpuLj9uGJOeo0jJ5wgnh4cb_CfCPbxGcw80","created_at":"1715760970"},"time":1715760970}
        }catch (Exception ex){

        }
        return null;
    }


    /**
     * 获取部门列表(已停用)--请使用departmentList2
     */
    public static void departmentList() {
        Map<String,Object> map = new HashMap<>();
        //map.put("id",74);
        //https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=ACCESS_TOKEN&id=ID
        String String = HttpUtil.post("https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token="+postRequestWithSign(),map);
        System.out.println(String);
        //{"errcode":0,"errmsg":"ok","department":[{"id":11,"name":"网络科技","parentid":1,"order":99998000,"department_leader":["WuLiang"]},{"id":32,"name":"健萌项目部","parentid":11,"order":100000000,"department_leader":["WuLiang"]},{"id":33,"name":"集团数字化项目部","parentid":11,"order":100000500,"department_leader":[]},{"id":72,"name":"betterWE项目部","parentid":11,"order":100001000,"department_leader":[]},{"id":73,"name":"商业化部","parentid":11,"order":99997000,"department_leader":[]},{"id":74,"name":"研发中台","parentid":11,"order":99996000,"department_leader":[]},{"id":75,"name":"设计中台","parentid":11,"order":99995000,"department_leader":[]},{"id":76,"name":"营养中台","parentid":11,"order":99994000,"department_leader":[]},{"id":77,"name":"自有流量部","parentid":11,"order":99993000,"department_leader":[]},{"id":78,"name":"前端组","parentid":74,"order":100000000,"department_leader":["suqingsong"]},{"id":79,"name":"后端组","parentid":74,"order":99999000,"department_leader":[]},{"id":80,"name":"测试组","parentid":74,"order":99998000,"department_leader":[]},{"id":81,"name":"客户端组","parentid":74,"order":99997000,"department_leader":[]}]}

    }
    /**
     * 获取部门列表
     */
    public static void departmentList2() {
        String String = HttpUtil.get("https://qyapi.weixin.qq.com/cgi-bin/department/simplelist?id=1&access_token="+postRequestWithSign());
        System.out.println(String);

    }

    /**
     * 查询成员的外部客户联系人
     */
    public static void list() {
        //String String = HttpUtil.get(" https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token="+postRequestWithSign()+"&userid=YangLin");
        //{"errcode":0,"errmsg":"ok","external_userid":["wmZw2MCQAA8qnaZh77TOabL5YLh01K2A","wmZw2MCQAAdLkPBlfPhINmFjaxhUswkQ","wmZw2MCQAAJcakZBnASSxAmw3vVpHBwg","wmZw2MCQAAJhG6TMk6sBFYHTHWKt7cPA","wmZw2MCQAArx3jAyw-OTjea0TET_AB8A"]}

        //String String = HttpUtil.get(" https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token="+postRequestWithSign()+"&userid=ChenShuHan");
        //{"errcode":0,"errmsg":"ok","external_userid":["wmZw2MCQAA8qnaZh77TOabL5YLh01K2A","wmZw2MCQAAJcakZBnASSxAmw3vVpHBwg","wmZw2MCQAAMj29vw-NyBjOM_w5Z35oUw","wmZw2MCQAA4djShWsDH9xJvrpgU2lLGQ","wmZw2MCQAAJhG6TMk6sBFYHTHWKt7cPA","wmZw2MCQAAk07DVUmTIa8gUOgVc0O98g","wmZw2MCQAA2McO7k1sXis4PwV2YbSEdw","wmZw2MCQAAuAIbV7kp_HGlCuyuq5W8fw"]}

        //String String = HttpUtil.get(" https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token="+postRequestWithSign()+"&userid=ZengE");
        //{"errcode":0,"errmsg":"ok","external_userid":["wmZw2MCQAAK_CJmpbLUBq_lgmtOmH1xQ"]}

        //System.out.println(String);
    }

    public static void add_msg_template() {
        Map<String,Object> map = new HashMap<>();
        map.put("chat_type","single");
        map.put("external_userid",new String[]{"YangLin"});
        map.put("text","{\"content\":\"你好，欢迎加入减脂营。\"}");
        String String = HttpUtil.post("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token="+postRequestWithSign(),map);
        System.out.println(String);

    }

    /**
     * 通过手机号查询企业微信userid
     */
    public static void getuserid() {
        JSONObject body = new JSONObject();
        body.set("mobile","13670279423");//手机号会自动截取11位
        //body.set("mobile","132792550681");
        //{"errcode":0,"errmsg":"ok","userid":"YangLin"}
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token="+postRequestWithSign(),null, body);
        System.out.println(String);
    }

    /**
     * 获取成员ID列表
     */
    public static void getUserList(){
        Map<String,Object> map = new HashMap<>();
        //map.put("cursor",10);
        map.put("limit","100");
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token="+postRequestWithSign(),null,new JSONObject(map));
        System.out.println(String);
        //{"errcode":0,"next_cursor":"aef8nyhFTYBfpydXm6k5AKCJTZeyg1SxWsKy8KHutv0","errmsg":"ok","dept_user":[{"userid":"ZhangRuoLin","department":1},{"userid":"ZhangWanRu","department":1},{"userid":"ZhouJing","department":1},{"userid":"AiYingHua","department":1},{"userid":"LiWei","department":1},{"userid":"ChenShaoNan","department":1},{"userid":"ZhangXiangHui","department":1},{"userid":"5cdbee54adc4611bc4341bea99039d9e","department":1},{"userid":"GeYaoChu","department":1},{"userid":"YuTaiHua2","department":1}]}
        //{"errcode":0,"errmsg":"ok","dept_user":[{"userid":"ZhangRuoLin","department":1},{"userid":"ZhangWanRu","department":1},{"userid":"ZhouJing","department":1},{"userid":"AiYingHua","department":1},{"userid":"LiWei","department":1},{"userid":"ChenShaoNan","department":1},{"userid":"ZhangXiangHui","department":1},{"userid":"5cdbee54adc4611bc4341bea99039d9e","department":1},{"userid":"GeYaoChu","department":1},{"userid":"YuTaiHua2","department":1},{"userid":"CanYingLiDeNiuDian","department":1},{"userid":"TanHanWen","department":1},{"userid":"MingXingYingYangShiZhuJiaocitizen","department":1},{"userid":"PeiBanGuanHanHan2Hao","department":1},{"userid":"XiongFangFang","department":1},{"userid":"JianZhiYingPeiBanGuanOO","department":1},{"userid":"TanMin","department":1},{"userid":"DengKaiXu","department":1},{"userid":"QuQian-TongTong","department":1},{"userid":"XuTingTing","department":1},{"userid":"TangHaiSha","department":1},{"userid":"DingXiaoWang","department":1},{"userid":"XiaoJie","department":1},{"userid":"QiYu","department":1},{"userid":"Hu","department":1},{"userid":"LiuYuan","department":1},{"userid":"RenZiMeng","department":1},{"userid":"TanHanWen_1","department":1},{"userid":"DaiQiaoYu","department":1},{"userid":"HeJiaLe","department":1},{"userid":"LiuZiYao","department":1},{"userid":"FangZhiMeng","department":1},{"userid":"wegymer_it","department":1},{"userid":"XiaYi","department":1},{"userid":"ZhangXinPing","department":1},{"userid":"WuBaiNi","department":1},{"userid":"PeiBanGuanHanHan","department":1},{"userid":"ZhouBin_1","department":1},{"userid":"TanJia","department":1},{"userid":"WuQinYue","department":1},{"userid":"LiLanFeng","department":1},{"userid":"ZhangRong","department":1},{"userid":"PeiBanGuanTaoTao","department":1},{"userid":"PeiBanGuanMuMu","department":1},{"userid":"ZhangYuHua","department":1},{"userid":"WangXia","department":3},{"userid":"TanRong","department":3},{"userid":"ZhangRuoLin_1","department":3},{"userid":"ZhangWanRu01","department":3},{"userid":"MaYingBo","department":4},{"userid":"MingXingYingYangShiZhuJiaoHuHu","department":4},{"userid":"YuanYuan","department":4},{"userid":"HeYuTing","department":4},{"userid":"AiYingHua_1","department":4},{"userid":"ShanDaWang","department":2},{"userid":"Fu","department":2},{"userid":"JiangPengub","department":2},{"userid":"WenYing","department":2},{"userid":"ollie","department":2},{"userid":"DeLuWeiYu","department":2},{"userid":"YangLin","department":2},{"userid":"ZhiMaChen","department":2},{"userid":"hong","department":2},{"userid":"al","department":2},{"userid":"Xin","department":2},{"userid":"YangZhuChangChangZhang","department":2},{"userid":"aliez","department":2},{"userid":"BoKaiYunWu","department":2},{"userid":"Jun","department":2},{"userid":"Yu","department":2},{"userid":"PuTong","department":2},{"userid":"CangLan","department":2},{"userid":"lcc","department":2},{"userid":"NianLi","department":2},{"userid":"emily","department":2},{"userid":"LiXiang","department":2},{"userid":"YouZhongKaFeiHenTian","department":2},{"userid":"WuLiang","department":2},{"userid":"YingYangShiLingLing","department":2},{"userid":"hola","department":2},{"userid":"tessie","department":2},{"userid":"HuaMin","department":2},{"userid":"BaiZe","department":2},{"userid":"XingHuoHangTu","department":2},{"userid":"hal-Hao","department":2},{"userid":"GuLuJiJi","department":2},{"userid":"wsNi","department":2},{"userid":"LanSeQiBing","department":2},{"userid":"back","department":2}]}
    }
    /**
     * 获取部门成员ID列表（已停用）--请使用getUserList
     */
    public static void getUserByDept(){
        JSONObject String = HttpUtils.doGet("https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?department_id=3&access_token="+postRequestWithSign());
        System.out.println(String);
    }

    private static void groupchatList() {
        Map<String,Object> map = new HashMap<>();
        map.put("limit",10);
        String String = HttpUtil.post("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/list?access_token="+postRequestWithSign(),map);
        System.out.println(String);
    }


    /**
     * 获取第三方平台的 AccessToken
     * @return
     * @throws Exception
     */
    protected static String postRequestWithSign1() {
        if("q".equals("q1")){
            return "e7aPYLG1QyTHbYonAxFv0TDIVqK7_77h9sdMHukk6EbOallWNR5FB8tMVG9fsAVOSVrx5jVZjp7khUP9Qamh1tkJkfBoY1qavRB5XI3SWvbla1W38ZAKYa_bkDT9LHTC8_6RgECZ-Yi8YwpgB7G5gfw6xdvhv69zDTWvFnzitoWN1HXRXWuZY9O_IektHfewE0RozvUW-CcwSD7UGF780w";
        }
        JSONObject body = new JSONObject();
        /*减脂营 crm测试版
        body.set("corpid", "wwbdeaa3266417c5e1");
        body.set("agentId", "1000035");*/

        /*body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", "1000009");//1000009 # 健萌教练端测试版*/
        //body.set("agentId", "employee");

        /*body.set("corpid", "ww381ac071e0265c14");
        body.set("agentId", "1000009");*/
        body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", "1000035");

        String sign = MD5.create().digestHex(body +"#56a81e404e85412d93ca4c2174b2abfc");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "84807357583");
        JSONObject result = HttpUtils.sendPost("https://twedata.gymcity.com.cn/openapi/third/getQiYeWeiXinToken", header, body);
        return result.getJSONObject("data").getStr("access_token");
    }

    /**
     * 获取第三方平台的 AccessToken
     * @return
     * @throws Exception
     */
    protected static String postRequestWithSign() {
        if("1000007".equals("10000071")){
            return "clGupBqRtGky0m6j_raczjoTxezO8N8bHqSS8twT54PmPlqgQVNVWqkadiI4dO7EROFI5mmp8behXCvBmuUVfMrsBI-KCZgxamc7nJouQEbQmrKvo8V7dzE1g3euZ5xz147-KeHDkizioQwOA7TuMuidjIhYL-z0P-3aYsa9Qa7cAfi7dS7iFEzuYKr3c7vEKYsHuz8Ohypw43-dUBg0Gw";
        }
        if("tongxunlu".equals("tongxunlu1")){
            return "cKObUs7RYg8jZY5wVCpMGhRS3ceAhfoXIThtmb8qZ_oHRgWiXkwdSoOS9H2E-GooA1kNNGwP2X4B8-bIZsRnq9_py_okcVWZkimvETxlFzCEWBQpMqO_Z_0YjlpS9-p5hh21qBbG6oq1BLGeLf8PYP6Hkq08ZOZTR1URWOF74GVyDRm_YbjDgc1jQVZ1wbxqDSU33pNh9h_faDSvNM9a0Q";
        }
        JSONObject body = new JSONObject();
        String url = "https://wedata.gymcity.com.cn/openapi/third/getQiYeWeiXinToken";
        /*body.set("corpid", "ww381ac071e0265c14");
        body.set("agentId", "1000008");//进线回调  （测试1000009） */
        /*body.set("corpid", "ww381ac071e0265c14");
        body.set("agentId", "1000007");//网络科技的减脂营SCRM*/

        /*body.set("corpid", "ww381ac071e0265c14");
        body.set("agentId", "tongxunlu");//网络科技的通讯录*/

        body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", "1000009");//健萌教练端测试版
        url = "https://twedata.gymcity.com.cn/openapi/third/getQiYeWeiXinToken";

        /*body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", "1000036");//健萌流量中心*/

        //body.set("corpid", "wwbb3eaebf35674eef");
        //body.set("agentId", "1000039");//总部通知中心

        String sign = MD5.create().digestHex(body +"#a5bc45af0b6c3c8a971b83812e35af0c");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "87075547368");
        JSONObject result = HttpUtils.sendPost(url, header, body);
        return result.getJSONObject("data").getStr("access_token");
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"errcode":0,"errmsg":"ok","access_token":"KK65NqHDcZ0lTFAZrFhJvXAPcXJw_VbYWKSYmYCXXwIGIKZgadQWb_iFiFP7p8PAddi2T8MQrwwhLNtVrTYPmL-BCw2t3ZGQrMqxMVo7W8sWldF4GchG_1ZbQJ-kX4Tx8ZTdQ7vqKGjGOTN7isMTwm-2SFvSHy-S8UbYOE1BGP7Wb-lJrS0TuKfOl3O4gCTz-SvIjWYK5xiN3vr4Z8KoWQ","expires_in":409},"time":1727338556}
        //sendPost result:   {"code":200,"msg":"操作成功","data":{"errcode":0,"errmsg":"ok","access_token":"KK65NqHDcZ0lTFAZrFhJvXAPcXJw_VbYWKSYmYCXXwIGIKZgadQWb_iFiFP7p8PAddi2T8MQrwwhLNtVrTYPmL-BCw2t3ZGQrMqxMVo7W8sWldF4GchG_1ZbQJ-kX4Tx8ZTdQ7vqKGjGOTN7isMTwm-2SFvSHy-S8UbYOE1BGP7Wb-lJrS0TuKfOl3O4gCTz-SvIjWYK5xiN3vr4Z8KoWQ","expires_in":1126},"time":1727337839}


    }

    /**
     * 删除部门
     */
    public static void deleteDept() {
        Map<String,Object> map = new HashMap<>();
        map.put("id",74);//	部门id。（注：不能删除根部门；不能删除含有子部门、成员的部门）
        //https://qyapi.weixin.qq.com/cgi-bin/department/delete?access_token=ACCESS_TOKEN&id=ID
        String String = HttpUtil.get("https://qyapi.weixin.qq.com/cgi-bin/department/delete?access_token="+postRequestWithSign(),map);
        System.out.println(String);
    }

    /**
     * 修改部门
     */
    public static void updateDept() {
        Map<String,Object> map = new HashMap<>();
        map.put("id", 79);
        map.put("name", "后端组");
        //sendRequest result:{"errcode":0,"errmsg":"updated"}
        //{"id":79,"name":"后端组","parentid":74,"order":99999000,"department_leader":[]},{"id":80,"name":"测试组","parentid":74,"order":99998000,"department_leader":[]}
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/department/update?access_token="+postRequestWithSign(),null,new JSONObject(map));
        System.out.println(String);

    }
    /**
     * 修改成员
     */
    public static void updateUser() {
        Map<String,Object> map = new HashMap<>();
        map.put("userid", "YangLin");
        map.put("name", "杨林");
        //sendRequest result:{"errcode":0,"errmsg":"updated"}
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token="+postRequestWithSign(),null,new JSONObject(map));
        System.out.println(String);
        //{"errcode":0,"errmsg":"updated"}
    }
    /**
     * 修改成员
     */
    public static void updateUser2() {
        Map<String,Object> map = new HashMap<>();
        map.put("userid", "YangLin");
        map.put("name", "杨林");
        //sendRequest result:{"errcode":0,"errmsg":"updated"}
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token="+postRequestWithSign(),null,new JSONObject(map));

        System.out.println(String);
        //{"errcode":0,"errmsg":"updated"}
    }
    /**
     * 创建成员
     */
    public static void createUser() {
        Map<String,Object> map = new HashMap<>();
        map.put("userid", "13279255068");//创建的时候，用系统ID
        map.put("name", "刘欣晟");
        map.put("mobile", "13279255068");
        map.put("gender", 1);//性别。1表示男性，2表示女性

        map.put("department", new Long[]{79L});
        map.put("position", "JAVA开发");
        //map.put("main_department", 79);

        //sendRequest result:{"errcode":0,"errmsg":"updated"}
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token="+postRequestWithSign(),null,new JSONObject(map));
        System.out.println(String);

    }
    /**
     * 更新成员
     */
    public static void updateUser3() {
        Map<String,Object> map = new HashMap<>();
        map.put("userid", "13279255068");//创建的时候，用系统ID
        map.put("name", "刘欣晟");
        map.put("mobile", "13279255068");
        map.put("gender", 1);//性别。1表示男性，2表示女性

        map.put("department", new Long[]{80L});
        map.put("position", "JAVA开发");
        map.put("main_department", 79);

        //sendRequest result:{"errcode":0,"errmsg":"updated"}
        JSONObject String = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token="+postRequestWithSign(),null,new JSONObject(map));
        System.out.println(String);
    }

    /**
     * 成员详情
     */
    public static void getUser(String userid) {
        Map<String,Object> map = new HashMap<>();
        map.put("userid",userid);
        String String = HttpUtil.get("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token="+postRequestWithSign(),map);
        System.out.println(String);
    }

}
